package com.xxx.modules.sys.controller;

import com.xxx.common.utils.R;
import com.xxx.modules.sys.service.UserAttentionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** 用户关注 controller
 * Created by ChenXuefei on 2017/10/17.
 */
@RestController
@Slf4j
public class SysUserAttentionController {

    @Autowired
    private UserAttentionService userAttentionService;

    /**
     *
     * @param attentionId 关注者id
     * @param isAttentionedId 被关注者id
     * @return
     */
    @RequestMapping("sys/user/attention/add")
    public R addUserAttention(String attentionId,String isAttentionedId){
        userAttentionService.addUserAttention(attentionId,isAttentionedId);
        log.debug("【"+attentionId+" 关注了 "+isAttentionedId+"】");
        return R.ok();
    }

    /**
     * 取消关注
     * @param attentionId
     * @param isAttentionedId
     * @return
     */
    @RequestMapping("sys/user/attention/delete")
    public R deleteUserAttention(String attentionId,String isAttentionedId){
        userAttentionService.updateUserAttentionState(attentionId,isAttentionedId);
        log.debug("【"+attentionId+" 取消关注 "+isAttentionedId+"】");
        return R.ok();
    }
}
